using System;
using System.Collections.Generic;
using System.Text;

namespace GPSCore
{
    /// <summary>
    /// Elevation degree
    /// </summary>
    public class Elevation : Angle, IComparable<Elevation>, IComparer<Elevation> , IEquatable<Elevation>
    {
        #region constructors

        /// <summary>
        /// Elevation base constructor
        /// </summary>
        public Elevation():base()
        {
            base.Max = 90.0;
            base.Min = -90.0;
            base.Behaviours = AngleBehaviours.FixedBounder;
        }


        /// <summary>
        /// Build a Elevation from an Angle
        /// </summary>
        /// <param name="Angle"></param>
        public Elevation(Angle Angle)
            : base(Angle)
        {
            base.Max = 90.0;
            base.Min = -90.0;
            base.Behaviours = AngleBehaviours.FixedBounder;
            base._normalize();
            base._splitData();
        }    
    

        /// <summary>
        /// Build an Elevation from a double value including information about H,M,S.dddd
        /// </summary>
        /// <param name="DecimalDegrees"></param>
        public Elevation(double DecimalDegrees)
            : base(DecimalDegrees)
        {
            base.Max = 90.0;
            base.Min = -90.0;
            base.Behaviours = AngleBehaviours.FixedBounder;

            base._value = DecimalDegrees;
            base._normalize();
            base._splitData();
        }

        /// <summary>
        /// Build a Elevation from an integer value of Degrees and a decimal value of Minutes
        /// </summary>
        /// <param name="IntDegrees"></param>
        /// <param name="DecimalMinutes"></param>
        public Elevation(int IntDegrees, double DecimalMinutes)
            : base(IntDegrees, DecimalMinutes)
        {
            base.Max = 90.0;
            base.Min = -90.0;
            base.Behaviours = AngleBehaviours.FixedBounder;
            base._normalize();
            base._splitData();       
        }

        /// <summary>
        /// Build a Elevation from a integer value of Degrees an integer Value of Minutes and a decimal value of Seconds
        /// </summary>
        /// <param name="IntDegrees"></param>
        /// <param name="IntMinutes"></param>
        /// <param name="DecimalSeconds"></param>
        public Elevation(int IntDegrees, int IntMinutes, double DecimalSeconds)
            : base(IntDegrees, IntMinutes , DecimalSeconds)
        {
            base.Max = 90.0;
            base.Min = -90.0;
            base.Behaviours = AngleBehaviours.FixedBounder;
            base._normalize();
            base._splitData();       
        }


        #endregion


        #region IComparable<Elevation> Members

        int IComparable<Elevation>.CompareTo(Elevation other)
        {
            if (this._value > other._value)
            {
                return 1;
            }
            else
            {
                if (this._value < other._value)
                {
                    return -1;
                }
                else
                {
                    return 0;
                }
            }
        }

        #endregion

        #region IComparer<Elevation> Members

        int IComparer<Elevation>.Compare(Elevation x, Elevation y)
        {
            if (x._value > y._value)
            {
                return 1;
            }
            else
            {
                if (x._value < y._value)
                {
                    return -1;
                }
                else
                {
                    return 0;
                }
            }
        }

        #endregion

        #region IEquatable<Elevation> Members
        
        /// <summary>
        /// Check Elevation Value
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(Elevation other)
        {
            if (this._value.Equals(other._value))
                return true;
            else
                return false;
        }

        #endregion
    }
}
